<?php
use \PsiFramework\Applications\AlloMediaPortal\Classes\Model\InformationPart;
use \PsiFramework\Classes\Factory\DAOFactory;
use \PsiFramework\Classes\Util\UI\Printer;
use \PsiFramework\Classes\Util\UI\HTML;
use \PsiFramework\Plugins\Form\Classes\DAO\FormResponseDAO;
use \PsiFramework\Plugins\Form\Classes\Util\FormUtil;

import("Plugins.Form.Classes.DAO.FormResponseDAO");
import("Plugins.Form.Classes.Util.FormUtil");

$entry = $response->getAttribute("entry");
$theme = $response->getAttribute("form");

$samplePart = new InformationPart();
$samplePart->setTheme($theme) ;
$samplePart->setProfile($entry->getCategory()->getprofile());
$informationPartDao = DAOFactory::getDAO('InformationPart') ;
$part = $informationPartDao->retrieveByPk($samplePart->getId()) ;
$currencySymbol = $response->getAttribute('Currency')->getSymbol();
?>
<article id="cont-princ" class="cols">
    <div style="float:right; text-align:right;"><?php echo HTML::link($languageManager->getText('EXAMPLE'), 'action=Preview&entry_id='.$entry->getId().'&example=true', array('class'=>'popup')); ?></div>
	<h1><?php Printer::display($languageManager->getText($theme->getTitle())) ?></h1>
	<div id="produit" class="fiche">
		<div class="pficheHaut">
			<div class="gauche">
				<div class="img-produit">
					<div class="slider-wrapper theme-default">
						<div id="slider" class="nivoSlider">
						<?php 
						$sliderImages = $theme->getSliderImages();
						if (!is_null($sliderImages)) {
						    for ($i=0;$i<$sliderImages->size();$i++) {
						        $currentImage = $sliderImages->getImage($i);
				        ?>
				            <img src="<?php Printer::display($currentImage->getImageLink()); ?>" alt="" data-transition="slideInLeft" />
				        <?php
						    }
						}
						?>
						</div>
					</div>
				</div>
			</div>
			<div class="droite">
				<div class="prix"><?php
				    $euros = floor($part->getPrice());
				    $cents = round(($part->getPrice()-$euros)*100);
				    if (strlen($cents) == 1) {
				        $cents .= '0' ;
				    }
				    echo $euros.$currencySymbol.'<sup>'.$cents.'</sup> <span class="woTaxes2">HT/mois</span>';
			    ?></div>
				<a class="btnAdd boxshadow" href="javascript:unlockTheme(<?php Printer::display($theme->getId().', '.$entry->getId()); ?>)">
				    <img src="./Images/AlloMedia/panier/btn_commander.png" alt="<?php Printer::display($languageManager->getText('ORDERING')); ?>" />
			    </a>
			</div>
		</div>
		<div class="pficheCorps">
			<div class="pficheDesc">
				<div class="img-produit"><?php
				if (!is_null($theme->getImage())) {
				?><img src="<?php Printer::display($theme->getImage()->getImageLink()); ?>" alt="" />
				<?php 
				}
				?></div>
				<div class="titre"><?php Printer::display($theme->getPresentationTitle()); ?></div>
				<?php echo $theme->getPresentation() ?>
			</div>
			<div class="pficheComp">
				<div class="img-produit"><?php if (!is_null($theme->getComplementImage())) {
				?><img src="<?php Printer::display($theme->getComplementImage()->getImageLink()); ?>" alt="" />
				<?php 
				}
				?></div>
				<div class="titre"><?php Printer::display($theme->getComplementTitle()); ?></div>
				<?php echo $theme->getComplement() ?>
			</div>
		</div>
		<div class="pfichebas">
			<div class="prix"><?php Printer::display(number_format($part->getPrice(), 2, '.', ' ').$currencySymbol); ?> <sup class="woTaxes">HT/mois</sup></div>
			<a class="btnAdd boxshadow" href="javascript:unlockTheme(<?php Printer::display($theme->getId().', '.$entry->getId()); ?>)"><?php Printer::display($languageManager->getText('ADD_TO_BASKET')); ?></a>
		</div>
	</div>
</article>
